@extends('admin.layout.layout')
@section('title','分类管理')

@section('con')
   
	<div class="admin">
  
    
    <div class="row">
            <h1 >分类列表</h1>
    </div>
     <form action="{{url('/admin/cate/index')}}">
    <div class="dataTables_filter" id="DataTables_Table_0_filter">
      <label><input type="text" name="keywords" value="{{$list['keywords'] or ''}}" aria-controls="DataTables_Table_0"><button class="btn btn-info">搜索</button></label>
      
    </div>
    </form>
    
    <div class="widget-box">
          <div class="widget-title"> <span class="icon"><i class="icon-th"></i></span>
            <h5>Data table</h5>

          </div>
          <div class="widget-content nopadding">
            <div role="grid" class="dataTables_wrapper" id="DataTables_Table_0_wrapper">
            <table class="table table-bordered data-table dataTable" id="DataTables_Table_0">
              <thead>
                <tr role="row" >
                    <th class="ui-state-default" style="font-size:15px;">分类ID</th>
                    <th class="ui-state-default" style="font-size:15px;">分类名称</th>
                    <th class="ui-state-default" style="font-size:15px;">所属分类</th>
                    <th class="ui-state-default" style="font-size:15px;">path路径</th>
                    <th class="ui-state-default" style="font-size:15px;">操作</th>
                 
                  
                </tr>
              </thead>
              
            
            @foreach($cates as $k=>$v)
            <tr >
                  <td class="  sorting_1">{{$v->tid}}</td>
                  <td class=" ">{{$v->tname}}</td>
                  <td >{{$v->pid}}</td>
                  <td class="center ">{{$v->path}}</td>
                  <td style="width:130px">
                   
                   <a href="/admin/cate/edit?tid={{$v->tid}}" class="btn btn-warning">修改</a>
                   <button class="btn btn-danger delete-btn">删除</button>
                  </td>

                </tr>
            @endforeach
            </table>
          </div>

        </div>
   
        
        
        
@endsection
@section('js')

     <script type="text/javascript">
     $.ajaxSetup({
        headers: {
            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
        }
      });
     //绑定单击事件
     $('.delete-btn').click(function(){
      var tid = $(this).parents('tr').find('.sorting_1').html();
      var btn = $(this);
    
     //发送ajax请求
     $.post('/admin/cate/delete',{tid:tid},function(data){
      if(data == 1){
        //删除成功
        alert('删除成功');
        btn.parents('tr').remove();
      }else{
        // 删除失败
        alert('删除失败');
      }
        })
    })
     </script>   

@endsection